﻿@using CodeGenerator.Models.TemplateModels
@inherits RazorEngine.Templating.TemplateBase<CodeGenerator.Models.TemplateModels.ServiceFileModel>
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Partner.Utility;
using Enterprise.Entities.Business.Dtos;
using Enterprise.Application.@(Model.DirName);
using Enterprise.Application.@(Model.DirName).Dto;

namespace Enterprise.Web.Controllers.ViewControllers.@Model.DirName
{
    public class @(Model.Name)Controller : EnterpriseControllerBase
    {
        public I@(Model.Name)AppService @(Model.Name)App { get; set; }

        /// <summary>
        /// 列表页
        ///</summary>
        /// <returns></returns>
        public IActionResult @(Model.Name)()
        {
            return View();
        }
        /// <summary>
        /// 编辑页
        ///</summary>
        /// <returns></returns>
        public IActionResult @(Model.Name)Edit()
        {
            return View();
        }

        /// <summary>
        /// 获取分页
        ///</summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> GetPageListAsync(Get@(Model.Name)sInput input)
        {
            var result = await @(Model.Name)App.GetPaged(input);
            return Json(result);
        }

        /// <summary>
        /// 添加|编辑
        ///</summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult>CreateOrUpdate(@(Model.Name)EditDto input)
        {
            await @(Model.Name)App.CreateOrUpdate(new CreateOrUpdate@(Model.Name)Input { @(Model.Name) = input }) ;
            return Json(new BizResult<bool>                { Success=true,Data=true });
        }
  
        /// <summary>
        /// 删除
        ///</summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> Delete(Args args)
        {
            await @(Model.Name)App.BatchDelete(args.input);
            return Json(new BizResult<string>{ Success = true, Message = "修改成功" });
        }

    }
}
